//
//  UIButton+Extension.swift
//  SinaMicroBlog
//
//  Created by wxy on 15/9/8.
//  Copyright © 2015年 wxy. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(title: String, imageName: String, color: UIColor, fontSize: CGFloat) {
        self.init()
        
        setTitle(title, forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitleColor(color, forState: UIControlState.Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        
    }
    
    // 便利构造
    convenience init(imageName: String) {
        self.init()
        
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        
        sizeToFit()
        
    }
}
